#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        if (s.empty())
            return 0;
        int left = 0, right = 1;
        int len = 1;
        auto it = s.begin();
        while (s[left] && s[right]) {
            if (string(it + left, it + right).find(s[right]) != -1) {
                len = max(len, abs(right - left));
                left++;
            }
            else {
                right++;

            }
        }
        if (s[right] == '\0')
            len = max(len, right - left);
        return len;
    }
};